package com.arrake.pojo;


import java.io.*;

class RelationShip {
    private String preRelationship;
    private String sufRelationship;
    private static volatile RelationShip relationShip;
    public static RelationShip getInstanceRelationShip(){
        if(relationShip == null){
            synchronized (RelationShip.class){
                if(relationShip == null) {
                    relationShip = new RelationShip();
                }
            }

        }
        return relationShip;
    }
    public void cleanInstanceRelationShip(){
        relationShip = new RelationShip();
    }
    private RelationShip() {
        preRelationship = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
                "<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">\n";
        sufRelationship = "</Relationships>\n";
    }

    public void AddNode(String picRelationdship) {
        preRelationship = preRelationship + picRelationdship;
    }
    //创建document.xml.rels文件
    public void createRelationship() throws Exception {
        String res;
        res = preRelationship + sufRelationship;
        OutputStream out = new FileOutputStream( new File("src\\main\\resources\\docxTemplate\\word\\_rels\\document.xml.rels"));
        PrintStream ps = new PrintStream(out);
        ps.println(res);

        ps.close();
        out.close();
    }
}
